import {LogFactory} from "../log"
import {isController} from "../util/internalTypeUtil"
import {HttpMethod} from "../enum/HttpMethod"

const logger = LogFactory.getLogger("@RequestMapping")


export function RequestMapping(path, method: HttpMethod = HttpMethod.ALL): MethodDecorator {
  return (proto, key?, desc?) => {
    const Ctor = proto.constructor
    if(isController(Ctor)){
      Ctor[key] = {
        path, method
      } as MappingObject
    }
    return desc
  }
}
